﻿/*
 * 设计模式 - 过滤器模式
 */

var data = Enumerable.Range(0, 1000);

var filterA = new FilterA();
var filterB = new FilterB();

data = filterA.Filter(data);
data = filterB.Filter(data);

foreach (var i in data)
{
    Console.WriteLine(i);
}


interface IFilter
{
    public IEnumerable<int> Filter(IEnumerable<int> data);
}

class FilterA : IFilter
{
    public IEnumerable<int> Filter(IEnumerable<int> data)
    {
        if (data.Sum() > 100)
        {
            return data.Skip(10);
        }
        return data;
    }
}

class FilterB : IFilter
{
    public IEnumerable<int> Filter(IEnumerable<int> data)
    {
        if (data.Sum() > 50)
        {
            return data.Take(10);
        }
        return data;
    }
}